<?xml version="1.0" encoding="UTF-8"?>
<%@page contentType="text/html; charset=UTF-8" %>
<%
	// Liste des livres
	Session hSession = HibernateUtil.getSessionFactory().getCurrentSession();
	Collection<Book> books = hSession.createCriteria(Book.class).list();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
	<title>Bookstore :: Back office :: Livres</title>
	<%@include file="include.jsp" %>
</head>

<body>
	<%@include file="commun.jsp" %>
	
	<div class="contenuAvecMenu">
		<h2>Livres</h2>
		<div class="boite bleue">
			<img src="../resources/images/add.png" alt="" />
			<a href="editBook.jsp?action=ADD">Ajouter un livre</a>
			<table>
				<tr>
					<th class="etroite">Identifiant</th>
					<th class="large">Titre</th>
					<th class="large">Categorie</th>
					<th class="etroite">Photo</th>
					<th class="moyenne">Actions</th>
				</tr>
				<% for (Book book : books) { %>
				<tr>
					<td class="centree"><%=book.getId()%></td>
					<td><%=book%></td>
					<td><%=book.getCategory()%></td>
					<td class="centree"><%=book.getPhoto() != null ? "Oui" : "Non"%></td>
					<td class="centree">
						<a href="editBook.jsp?action=EDIT&amp;id=<%=book.getId()%>" title="Modifier">
							<img src="../resources/images/pencil.png" alt="Modifier" />
						</a>
						&middot;
						<a href="uploadPhoto.jsp?id=<%=book.getId()%>" title="Envoyer une photo">
							<img src="../resources/images/photo_add.png" alt="Envoyer une photo" />
						</a>
						&middot;
						<a href="RemoveBook.do?id=<%=book.getId()%>" title="Supprimer">
							<img src="../resources/images/delete.png" alt="Supprimer" />
						</a>
					</td>
				</tr>
				<% } %>
			</table>
		</div>
	</div>
</body>
</html>
